//
//  segLastItem.m
//  SoundPill
//
//  Created by 宋鹏鹏 on 15/3/26.
//  Copyright (c) 2015年 宋旭东. All rights reserved.
//

#import "segLastItem.h"

#define kDeviceHeight [UIScreen mainScreen].bounds.size.height
#define kDeviceWidth  [UIScreen mainScreen].bounds.size.width

#define kTitleScale 0.7
// 设置宽高
#define kMenuItemW kDeviceWidth/3
#define kMenuItemH 35

@implementation segLastItem
- (id)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        // 1.文字颜色
        [self setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
        //[self setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
        
        self.titleLabel.textAlignment = NSTextAlignmentCenter;
        self.titleLabel.font = [UIFont systemFontOfSize:15];
        
        // 2.设置图标
        // [self setImage:[UIImage imageNamed:@"ic_arrow_down.png"] forState:UIControlStateNormal];
        
        self.imageView.contentMode = UIViewContentModeScaleAspectFit;
        
        // 3.上边的分割线
        UIImage *upImg = [UIImage imageNamed:@"gray_line"];
        UIImageView *updivider = [[UIImageView alloc] initWithImage:upImg];
        updivider.bounds = CGRectMake(0, 0, kMenuItemW, 0.8);
        updivider.center = CGPointMake(kMenuItemW/2, 0.4);
        [self addSubview:updivider];
        // 3.下边的分割线
        UIImage *downImg = [UIImage imageNamed:@"gray_line"];
        UIImageView *downDivider = [[UIImageView alloc] initWithImage:downImg];
        downDivider.bounds = CGRectMake(0,0, kMenuItemW, 0.8 );
        downDivider.center = CGPointMake(kMenuItemW/2, kMenuItemH-0.4);
        [self addSubview:downDivider];
        

        
        self.backgroundColor = [UIColor whiteColor];
        //self.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"NavigationBackgroundImage"]];
        //self.backgroundColor = [UIColor colorWithRed:0.1 green:0.1 blue:0.1 alpha:0.1];
        
        //文字Label
        self.stringLabel = [[UILabel alloc]initWithFrame:CGRectMake(0, 0, kMenuItemW, kMenuItemH)];
        self.stringLabel.font = [UIFont boldSystemFontOfSize:14];
        self.stringLabel.textAlignment = NSTextAlignmentCenter;
        [self addSubview:self.stringLabel];
        
        self.count = [[UILabel alloc] initWithFrame:CGRectMake(52, kMenuItemH*0.25, kMenuItemW - 55, kMenuItemH * 0.5)];
        _count.textAlignment = NSTextAlignmentLeft;
        [self addSubview:_count];
    }
    return self;
}

- (void)setTitle:(NSString *)title
{
    _title = title;
    
    [self setTitle:title forState:UIControlStateNormal];
}

- (void)setFrame:(CGRect)frame
{
    frame.size = CGSizeMake(kMenuItemW, kMenuItemH);
    [super setFrame:frame];
}

- (CGRect)titleRectForContentRect:(CGRect)contentRect
{
    CGFloat h = contentRect.size.height/2-1;
    CGFloat w = contentRect.size.width;
    return CGRectMake(0, 1, w, h);

}

- (CGRect)imageRectForContentRect:(CGRect)contentRect
{
    CGFloat h = contentRect.size.height/2 -9.7;
    CGFloat w = contentRect.size.width*0.9;
    
    return CGRectMake(contentRect.size.width*0.05, contentRect.size.height * 0.53, w, h);
}



@end
